#include<iostream>
#include<functional>
#include<string>
#include<map>

int add(int i , int j){
	return i + j;
}

auto mutiple = [](int i , int j){
	return i * j;
};

struct divide{
	int operator()(int i , int j){
		return i / j;
	}
};

int main(void){
	using namespace std;
	
	function<int(int,int)> f1 = add;
	function<int(int,int)> f2 = divide();
	function<int(int,int)> f3 = [](int i , int j){
									return i * j;
								};
								
	cout<<f1(4,2)<<endl; 	
	cout<<f2(4,2)<<endl; 
	cout<<f3(4,2)<<endl; 	
	
	map<string,function<int(int,int)>> binops = {//pair对象
		{"+",add},//普通函数
		{"-",minus<int>()},//重载函数调用操作符，std命名空间
		{"/",divide()},//重载函数调用操作符，自己定义
		{"*",[](int i , int j){return i * j;}},//lambda
	};
	//调用
	cout<<binops["+"](4,2)<<endl; 	
	cout<<binops["-"](4,2)<<endl; 
	cout<<binops["/"](4,2)<<endl; 
	cout<<binops["*"](4,2)<<endl; 
	return 0;
}